<?php

namespace api\controller;

// +----------------------------------------------------------------------
// | 角色数据控制层
// +----------------------------------------------------------------------

use common\controller\VerifyController;
use common\service\RoleService;
use think\Request;

class RoleController extends VerifyController
{
    /**
     * @var \common\service\RoleService
     */
    protected $roleService;


    public function __construct()
    {
        parent::__construct();
        $this->roleService = new RoleService();
    }

    /**
     * 获取角色列表
     * @param Request $request
     * @return \think\Response
     */
    public function select(Request $request)
    {
        $param = $request->param();
        $resParam = [];
        if (array_key_exists('param', $param)) {
            $resParam = $param['param'];
        }
        $resData = $this->roleService->select($resParam);
        return json(success_response('Get Role list successfully.', $resData));
    }

    /**
     * 非平台角色查询
     * @param Request $request
     * @return \think\Response
     */
    public function selectNormalList(Request $request)
    {
        $param = $request->param();
        $resParam = [];
        if (array_key_exists('param', $param)) {
            $resParam = $param['param'];
        }
        $resParam['filter'][] = [
            'role.is_platform' => 'no'
        ];
        $resData = $this->roleService->select($resParam);
        return json(success_response('Get Role list successfully.', $resData));
    }
}